import { getRouterParam } from 'h3'
import { getCategoryApps } from '~/server/plugins/apps'

export default defineEventHandler(async (event) => {
  const categoryName = getRouterParam(event, 'categoryName')
  console.log('正在获取分类数据:', categoryName)
  
  if (!categoryName) {
    return { error: '缺少 categoryName 参数' }
  }

  try {
    // 直接获取对应分类文件的数据
    const categoryApps = getCategoryApps(categoryName)
    console.log('找到应用数量:', categoryApps.length)
    
    return categoryApps
  } catch (error) {
    console.error('Error getting category apps:', error)
    return []
  }
})